package com.engr.lyx.gateway.biz.config;

import com.google.common.collect.Lists;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.List;

/**
 * @program: blog
 * @desc: swagger网关配置
 * @author: lyx
 * @date: 2019-04-25 10:11
 **/
@Component
@Primary
public class SwaggerDocumentConfig implements SwaggerResourcesProvider {

    @Override
    public List<SwaggerResource> get() {

        List<SwaggerResource> resource = Lists.newArrayList();
        resource.add(swaggerResource("认证中心", "/auth/v2/api-docs", "2.0"));
        resource.add(swaggerResource("用户中心", "/base/v2/api-docs", "2.0"));
        resource.add(swaggerResource("APP接口", "/article/v2/api-docs", "2.0"));
        return resource;
    }

    private SwaggerResource swaggerResource(String name, String location, String version) {

        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}
